// pages/update/update.js
var app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isSelect1:false,//展示类型？
    types:['华港区','凯旋区'],
  },
  select:function(){
    var isSelect1 = this.data.isSelect1
    this.setData({ isSelect1:!isSelect1})
  },
  //点击下拉框选项，选中并隐藏下拉框
  getType:function(e){
    let value = e.currentTarget.dataset.type
    this.setData({
      bankArea:value ,
      isSelect1: false,
    })
  },
  city:function(e){
    var that=this
    let city=e.detail.value
    that.setData({
      city:city
    })
  },
  name:function(e){
    var that=this
    let name=e.detail.value
    that.setData({
      clientName:name
    })
  },
  id:function(e){
    var that=this
    var id=e.detail.value
    that.setData({
      clientIdNumber:id
    })
  },
  code1:function(e){
    var that=this
    var code1=e.detail.value
    that.setData({
      carNumber:code1
    })
  },
  code2:function(e){
    var that=this
    var code2=e.detail.value
    that.setData({
      engineNumber:code2
    })
  },
  code3:function(e){
    var that=this
    var code3=e.detail.value
    that.setData({
      phoneNumber:code3
    })
  },
  code4:function(e){
    var that=this
    var code4=e.detail.value
    that.setData({
      carType:code4
    })
  },
  length:function(e){
    var that=this
    var length=e.detail.value
    that.setData({
      serviceLife:length
    })
  },

  value:function(e){
    var that=this
    var value=e.detail.value
    that.setData({
      presentWorth:value
    })
  },
  gold:function(e){
    var that=this
    var gold=e.detail.value
    that.setData({
      loanAmount:gold
    })
  },
  year:function(e){
    var that=this
    var year=e.detail.value
    that.setData({
      loanTerm:year
    })
  },
  bindDateChange: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      date: e.detail.value
    })
  },
upload:function(){
  var that=this
  for(var i=0;i<that.data.tempFilePaths.length;i++){
    wx.uploadFile({
      url:  app.globalData.url+'/client/upload',
      name: 'file',
      filePath:that.data.tempFilePaths[i],
      formData:{
        'type':'hukouben'+[i],
        'clientIdNumber':wx.getStorageSync('which')
      },
      header: {
        "Content-Type": "multipart/form-data",
        "token":app.globalData.token
      },
      success(req){
        console.log(req)
        console.log(that.data.clientIdNumber)
      }
    })
  }
},
upload1:function(){
  var that=this
  for(var i=0;i<that.data.tempFilePaths1.length;i++){
    wx.uploadFile({
      url:  app.globalData.url+'/client/upload',
      name: 'file',
      filePath:that.data.tempFilePaths1[i],
      formData:{
        'type':'shenfenzheng'+[i],
        'clientIdNumber':wx.getStorageSync('which')
      },
      header: {
        "Content-Type": "multipart/form-data",
        "token":app.globalData.token
      },
      success(req){
        console.log(req)
        console.log()
      }
    })
  }
},

upload2:function(){
  var that=this
  for(var i=0;i<that.data.tempFilePaths2.length;i++){
    wx.uploadFile({
      url:  app.globalData.url+'/client/upload',
      name: 'file',
      filePath:that.data.tempFilePaths2[i],
      formData:{
        'type':'jiehunzheng'+[i],
        'clientIdNumber':wx.getStorageSync('which')
      },
      header: {
        "Content-Type": "multipart/form-data",
        "token":app.globalData.token
      },
      success(req){
        console.log(req)
        console.log()
      }
    })
  }
},
upload3:function(){
  var that=this
  for(var i=0;i<that.data.tempFilePaths3.length;i++){
    wx.uploadFile({
      url:  app.globalData.url+'/client/upload',
      name: 'file',
      filePath:that.data.tempFilePaths3[i],
      formData:{
        'type':'zhengxin'+[i],
        'clientIdNumber':wx.getStorageSync('which')
      },
      header: {
        "Content-Type": "multipart/form-data",
        "token":app.globalData.token
      },
      success(req){
        console.log(req)
        console.log()
      }
    })
  }
},
upload4:function(){
  var that=this
  for(var i=0;i<that.data.tempFilePaths4.length;i++){
    wx.uploadFile({
      url:  app.globalData.url+'/client/upload',
      name: 'file',
      filePath:that.data.tempFilePaths4[i],
      formData:{
        'type':'fangchanzheng'+[i],
        'clientIdNumber':wx.getStorageSync('which')
      },
      header: {
        "Content-Type": "multipart/form-data",
        "token":app.globalData.token
      },
      success(req){
        console.log(req)
      }
    })
  }
},
upload5:function(){
  var that=this
  for(var i=0;i<that.data.tempFilePaths5.length;i++){
    wx.uploadFile({
      url:  app.globalData.url+'/client/upload',
      name: 'file',
      filePath:that.data.tempFilePaths5[i],
      formData:{
        'type':'xingshizheng'+[i],
        'clientIdNumber':wx.getStorageSync('which')
      },
      header: {
        "Content-Type": "multipart/form-data",
        "token":app.globalData.token
      },
      success(req){
        console.log(req)
        console.log()
      }
    })
  }
},
upload6:function(){
  var that=this
  for(var i=0;i<that.data.tempFilePaths6.length;i++){
    wx.uploadFile({
      url:  app.globalData.url+'/client/upload',
      name: 'file',
      filePath:that.data.tempFilePaths6[i],
      formData:{
        'type':'cheliangdazhao'+[i],
        'clientIdNumber':wx.getStorageSync('which')
      },
      header: {
        "Content-Type": "multipart/form-data",
        "token":app.globalData.token
      },
      success(req){
        console.log(req)
        console.log()
      }
    })
  }
},
upload7:function(){
  var that=this
  for(var i=0;i<that.data.tempFilePaths7.length;i++){
    wx.uploadFile({
      url:  app.globalData.url+'/client/upload',
      name: 'file',
      filePath:that.data.tempFilePaths7[i],
      formData:{
        'type':'buchongcailiao'+[i],
        'clientIdNumber':wx.getStorageSync('which')
      },
      header: {
        "Content-Type": "multipart/form-data",
        "token":app.globalData.token
      },
      success(req){
        console.log(req)
        console.log()
      }
    })
  }
},

  ChooseImg: function () {
    let that = this;
    wx.chooseImage({
      count: 9, // 默认最多9张图片，可自行更改
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: res => {
        wx.showToast({
          title: '正在上传...',
          icon: 'loading',
          mask: true,
          duration: 1000
        })
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        let tempFilePath = that.data.tempFilePaths.concat(res.tempFilePaths);
        that.setData({
          tempFilePaths: tempFilePath
        })
      }
    })
  },
  //预览图片
  PreviewImg: function (e) {
    let index = e.target.dataset.index;
    let that = this;
    //console.log(that.data.tempFilePaths[index]);
    //console.log(that.data.tempFilePaths);
    wx.previewImage({
      current: that.data.tempFilePaths[index],
      urls: that.data.tempFilePaths,
    })
  },
  //长按删除图片
  DeleteImg: function (e) {
    var that = this;
    var tempFilePaths = that.data.tempFilePaths;
    var index = e.currentTarget.dataset.index;//获取当前长按图片下标
    var src
    wx.showModal({
      title: '提示',
      content: '确定要删除此图片吗？',
      success: function (res) {
        if (res.confirm) {
          console.log('点击确定了');
          src=tempFilePaths.splice(index, 1);
          console.log(src)
          wx.request({
            url: app.globalData.url+'/client/deleteImage',
            method:'POST',
            data:{
              imagePath:src
            },
            header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
                    "token":app.globalData.token},
            success(res){
              console.log(res)
            }
          })
        } else if (res.cancel) {
          //console.log('点击取消了');
          return false;
        }
        that.setData({
          tempFilePaths
        });
      }
    })
  },
  ChooseImg1: function () {
    let that = this;
    wx.chooseImage({
      count: 9, // 默认最多9张图片，可自行更改
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: res => {
        wx.showToast({
          title: '正在上传...',
          icon: 'loading',
          mask: true,
          duration: 1000
        })
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        let tempFilePath = that.data.tempFilePaths1.concat(res.tempFilePaths);
        that.setData({
          tempFilePaths1: tempFilePath
        })
      }
    })
  },
  //预览图片
  PreviewImg1: function (e) {
    let index = e.target.dataset.index;
    let that = this;
    //console.log(that.data.tempFilePaths[index]);
    //console.log(that.data.tempFilePaths);
    wx.previewImage({
      current: that.data.tempFilePaths1[index],
      urls: that.data.tempFilePaths1,
    })
  },
  //长按删除图片
  DeleteImg1: function (e) {
    var that = this;
    var tempFilePaths1 = that.data.tempFilePaths1;
    var index = e.currentTarget.dataset.index;//获取当前长按图片下标
    var src
    wx.showModal({
      title: '提示',
      content: '确定要删除此图片吗？',
      success: function (res) {
        if (res.confirm) {
          //console.log('点击确定了');
          src=tempFilePaths1.splice(index, 1);
          wx.request({
            url: app.globalData.url+'/client/deleteImage',
            method:'POST',
            data:{
              imagePath:src
            },
            header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
                    "token":app.globalData.token},
            success(res){
              console.log(res)
            }
          })
        } else if (res.cancel) {
          //console.log('点击取消了');
          return false;
        }
        that.setData({
          tempFilePaths1
        });
      }
    })
  },
  ChooseImg2: function () {
    let that = this;
    wx.chooseImage({
      count: 9, // 默认最多9张图片，可自行更改
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: res => {
        wx.showToast({
          title: '正在上传...',
          icon: 'loading',
          mask: true,
          duration: 1000
        })
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        let tempFilePath = that.data.tempFilePaths2.concat(res.tempFilePaths);
        that.setData({
          tempFilePaths2: tempFilePath
        })
      }
    })
  },
  //预览图片
  PreviewImg2: function (e) {
    let index = e.target.dataset.index;
    let that = this;
    //console.log(that.data.tempFilePaths[index]);
    //console.log(that.data.tempFilePaths);
    wx.previewImage({
      current: that.data.tempFilePaths2[index],
      urls: that.data.tempFilePaths2,
    })
  },
  //长按删除图片
  DeleteImg2: function (e) {
    var that = this;
    var tempFilePaths2 = that.data.tempFilePaths2;
    var index = e.currentTarget.dataset.index;//获取当前长按图片下标
    var src
    wx.showModal({
      title: '提示',
      content: '确定要删除此图片吗？',
      success: function (res) {
        if (res.confirm) {
          //console.log('点击确定了');
          src=tempFilePaths2.splice(index, 1);
          wx.request({
            url: app.globalData.url+'/client/deleteImage',
            method:'POST',
            data:{
              imagePath:src
            },
            header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
                    "token":app.globalData.token},
            success(res){
              console.log(res)
            }
          })
        } else if (res.cancel) {
          //console.log('点击取消了');
          return false;
        }
        that.setData({
          tempFilePaths2
        });
      }
    })
  },
  ChooseImg3: function () {
    let that = this;
    wx.chooseImage({
      count: 9, // 默认最多9张图片，可自行更改
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: res => {
        wx.showToast({
          title: '正在上传...',
          icon: 'loading',
          mask: true,
          duration: 1000
        })
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        let tempFilePath = that.data.tempFilePaths3.concat(res.tempFilePaths);
        that.setData({
          tempFilePaths3: tempFilePath
        })
      }
    })
  },
  //预览图片
  PreviewImg3: function (e) {
    let index = e.target.dataset.index;
    let that = this;
    //console.log(that.data.tempFilePaths[index]);
    //console.log(that.data.tempFilePaths);
    wx.previewImage({
      current: that.data.tempFilePaths3[index],
      urls: that.data.tempFilePaths3,
    })
  },
  //长按删除图片
  DeleteImg3: function (e) {
    var that = this;
    var tempFilePaths3 = that.data.tempFilePaths3;
    var index = e.currentTarget.dataset.index;//获取当前长按图片下标
    var src
    wx.showModal({
      title: '提示',
      content: '确定要删除此图片吗？',
      success: function (res) {
        if (res.confirm) {
          //console.log('点击确定了');
          src=tempFilePaths3.splice(index, 1);
          wx.request({
            url: app.globalData.url+'/client/deleteImage',
            method:'POST',
            data:{
              imagePath:src
            },
            header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
                    "token":app.globalData.token},
            success(res){
              console.log(res)
            }
          })
        } else if (res.cancel) {
          //console.log('点击取消了');
          return false;
        }
        that.setData({
          tempFilePaths3
        });
      }
    })
  },
  ChooseImg4: function () {
    let that = this;
    wx.chooseImage({
      count: 9, // 默认最多9张图片，可自行更改
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: res => {
        wx.showToast({
          title: '正在上传...',
          icon: 'loading',
          mask: true,
          duration: 1000
        })
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        let tempFilePath = that.data.tempFilePaths4.concat(res.tempFilePaths);
        that.setData({
          tempFilePaths4: tempFilePath
        })
      }
    })
  },
  //预览图片
  PreviewImg4: function (e) {
    let index = e.target.dataset.index;
    let that = this;
    //console.log(that.data.tempFilePaths[index]);
    //console.log(that.data.tempFilePaths);
    wx.previewImage({
      current: that.data.tempFilePaths4[index],
      urls: that.data.tempFilePaths4,
    })
  },
  //长按删除图片
  DeleteImg4: function (e) {
    var that = this;
    var tempFilePaths4 = that.data.tempFilePaths4;
    var index = e.currentTarget.dataset.index;//获取当前长按图片下标
    var src
    wx.showModal({
      title: '提示',
      content: '确定要删除此图片吗？',
      success: function (res) {
        if (res.confirm) {
          //console.log('点击确定了');
          src=tempFilePaths4.splice(index, 1);
          wx.request({
            url: app.globalData.url+'/client/deleteImage',
            method:'POST',
            data:{
              imagePath:src
            },
            header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
                    "token":app.globalData.token},
            success(res){
              console.log(res)
            }
          })
        } else if (res.cancel) {
          //console.log('点击取消了');
          return false;
        }
        that.setData({
          tempFilePaths4
        });
      }
    })
  },
  ChooseImg5: function () {
    let that = this;
    wx.chooseImage({
      count: 9, // 默认最多9张图片，可自行更改
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: res => {
        wx.showToast({
          title: '正在上传...',
          icon: 'loading',
          mask: true,
          duration: 1000
        })
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        let tempFilePath = that.data.tempFilePaths5.concat(res.tempFilePaths);
        that.setData({
          tempFilePaths5: tempFilePath
        })
      }
    })
  },
  //预览图片
  PreviewImg5: function (e) {
    let index = e.target.dataset.index;
    let that = this;
    //console.log(that.data.tempFilePaths[index]);
    //console.log(that.data.tempFilePaths);
    wx.previewImage({
      current: that.data.tempFilePaths5[index],
      urls: that.data.tempFilePaths5,
    })
  },
  //长按删除图片
  DeleteImg5: function (e) {
    var that = this;
    var tempFilePaths5 = that.data.tempFilePaths5;
    var index = e.currentTarget.dataset.index;//获取当前长按图片下标
    var src
    wx.showModal({
      title: '提示',
      content: '确定要删除此图片吗？',
      success: function (res) {
        if (res.confirm) {
          //console.log('点击确定了');
          src=tempFilePaths5.splice(index, 1);
          wx.request({
            url: app.globalData.url+'/client/deleteImage',
            method:'POST',
            data:{
              imagePath:src
            },
            header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
                    "token":app.globalData.token},
            success(res){
              console.log(res)
            }
          })
        } else if (res.cancel) {
          //console.log('点击取消了');
          return false;
        }
        that.setData({
          tempFilePaths5
        });
      }
    })
  },
  ChooseImg6: function () {
    let that = this;
    wx.chooseImage({
      count: 9, // 默认最多9张图片，可自行更改
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: res => {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        let tempFilePath = that.data.tempFilePaths6.concat(res.tempFilePaths);
        that.setData({
          tempFilePaths6:tempFilePath
        })
      }
    })
  },
  //预览图片
  PreviewImg6: function (e) {
    let index = e.target.dataset.index;
    let that = this;
    //console.log(that.data.tempFilePaths[index]);
    //console.log(that.data.tempFilePaths);
    wx.previewImage({
      current: that.data.tempFilePaths6[index],
      urls: that.data.tempFilePaths6,
    })
  },
  //长按删除图片
  DeleteImg6: function (e) {
    var that = this;
    var tempFilePaths6 = that.data.tempFilePaths6;
    var index = e.currentTarget.dataset.index;//获取当前长按图片下标
    var src
    wx.showModal({
      title: '提示',
      content: '确定要删除此图片吗？',
      success: function (res) {
        if (res.confirm) {
          //console.log('点击确定了');
          src=tempFilePaths6.splice(index, 1);
          wx.request({
            url: app.globalData.url+'/client/deleteImage',
            method:'POST',
            data:{
              imagePath:src
            },
            header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
                    "token":app.globalData.token},
            success(res){
              console.log(res)
            }
          })
        } else if (res.cancel) {
          //console.log('点击取消了');
          return false;
        }
        that.setData({
          tempFilePaths6
        });
      }
    })
  },
  ChooseImg7: function () {
    let that = this;
    wx.chooseImage({
      count: 9, // 默认最多9张图片，可自行更改
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: res => {
        wx.showToast({
          title: '正在上传...',
          icon: 'loading',
          mask: true,
          duration: 1000
        })
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        let tempFilePath = that.data.tempFilePaths7.concat(res.tempFilePaths);
        that.setData({
          tempFilePaths7: tempFilePath
        })
      }
    })
  },
  //预览图片
  PreviewImg7: function (e) {
    let index = e.target.dataset.index;
    let that = this;
    //console.log(that.data.tempFilePaths[index]);
    //console.log(that.data.tempFilePaths);
    wx.previewImage({
      current: that.data.tempFilePaths7[index],
      urls: that.data.tempFilePaths7,
    })
  },
  //长按删除图片
  DeleteImg7: function (e) {
    var that = this;
    var tempFilePaths7 = that.data.tempFilePaths7;
    var index = e.currentTarget.dataset.index;//获取当前长按图片下标
    var src
    wx.showModal({
      title: '提示',
      content: '确定要删除此图片吗？',
      success: function (res) {
        if (res.confirm) {
          //console.log('点击确定了');
          src=tempFilePaths7.splice(index, 1);
          wx.request({
            url: app.globalData.url+'/client/deleteImage',
            method:'POST',
            data:{
              imagePath:src
            },
            header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
                    "token":app.globalData.token},
            success(res){
              console.log(res)
            }
          })
        } else if (res.cancel) {
          //console.log('点击取消了');
          return false;
        }
        that.setData({
          tempFilePaths7
        });
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this
    wx.request({
      url: app.globalData.url+'/client/check',
      method:'POST',
      data:{
        clientId:wx.getStorageSync('which')
      },
      header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
              "token":app.globalData.token},
      success(res){
        console.log(res)
        console.log(res.data.data.approvalState)
        if(res.data.data.approvalState==1&&app.globalData.role==2){
          app.globalData.isShow3=true
          console.log(app.globalData.isShow3)
        }
        if(res.data.data.approvalState==2&&app.globalData.role==1){
          app.globalData.isShow0=true
        }
        if(res.data.data.approvalState==3&&app.globalData.role==1){
          app.globalData.isShow1=true
          app.globalData.isShow2=true
          app.globalData.isShow4=true
        }
        if(res.data.data.approvalState==4&&app.globalData.role==2){
          app.globalData.isShow5=true
        }
        if(res.data.data.approvalState==1){
            res.data.data.approvalState='待审核'
        }
        if(res.data.data.approvalState==2){
          res.data.data.approvalState='待过户'
        }
        if(res.data.data.approvalState==3){
          res.data.data.approvalState='待抵押'
          
        }
        if(res.data.data.approvalState==4){
          res.data.data.approvalState='待放款'
        }

        if(res.data.data.approvalState==5){
          res.data.data.approvalState='已放款'
        }
        if(res.data.data.approvalState==6){
          res.data.data.approvalState='审核拒绝'
        }
        console.log(res.data.data.images)
        that.setData({
          tempFilePaths:res.data.data.images.hukouben
        })
        that.setData({
          tempFilePaths1:res.data.data.images.shenfenzheng
        })
        that.setData({
          tempFilePaths2:res.data.data.images.jiehunzheng
        })
        that.setData({
          tempFilePaths3:res.data.data.images.zhengxin
        })
        that.setData({
          tempFilePaths4:res.data.data.images.fangchanzheng
        })
        that.setData({
          tempFilePaths5:res.data.data.images.xingshizheng
        })
        that.setData({
          tempFilePaths6:res.data.data.images.cheliangdazhao
        })
        that.setData({
          tempFilePaths7:res.data.data.images.buchongcailiao
        })
        that.setData({
          name:res.data.data.clientName,
          clientIdNumber:res.data.data.clientIdNumber,
          carNumber:res.data.data.carNumber,
          engineNumber:res.data.data.engineNumber,
          serviceLife:res.data.data.serviceLife,
          orderTime:res.data.data.orderTime,
          presentWorth:res.data.data.presentWorth,
          registrationTime:res.data.data.registrationTime,
          salesman:res.data.data.salesman,
          loanAmount:res.data.data.loanAmount,
          approvalState:res.data.data.approvalState,
          bankArea:res.data.data.bankArea,
          loanTerm:res.data.data.loanTerm,
          clientName:res.data.data.clientName,
          deadline:res.data.data.deadline,
          phoneNumber:res.data.data.phoneNumber,
          carType:res.data.data.carType,
          date:res.data.data.registrationTime,
          bankArea:res.data.data.bankArea,
          city:res.data.data.city
        })
        app.globalData.realname=that.data.clientName
        app.globalData.idcard=that.data.clientIdNumber
        app.globalData.frameno=that.data.carNumber
        console.log(app.globalData.realname)
        console.log(app.globalData.idcard)
      }
    })
    console.log(that.data)
  },
  submit:function(){
    var that=this
    if(that.data.clientIdNumber.length==18&&that.data.phoneNumber.length==11){
      console.log(that.data.clientName)
      if(app.globalData.role==1){
        wx.switchTab({
          url: '/pages/to-do/to-do',
        })
      }
      else{
        wx.redirectTo({
          url: '/pages/admin/admin',
        })
      }
      wx.request({
        url: app.globalData.url+'/client/updateClient',
        method:'POST',
        data:{
          clientId:wx.getStorageSync('which'),
          clientName:that.data.clientName,
          clientIdNumber:that.data.clientIdNumber,
          carNumber:that.data.carNumber,
          engineNumber:that.data.engineNumber,
          serviceLife:parseFloat(that.data.serviceLife),
          registrationTime:that.data.date,
          presentWorth:parseFloat(that.data.presentWorth),
          loanAmount:parseFloat(that.data.loanAmount),
          loanTerm:parseInt(that.data.loanTerm),
          carType:that.data.carType,
          phoneNumber:that.data.phoneNumber,
          bankArea:that.data.bankArea,
          clientId:wx.getStorageSync('which'),
          approvalState:1,
          city:that.data.city
        },
        header:{"content-type":"application/x-www-form-urlencoded;charset=utf-8",
                "token":app.globalData.token},
        success(res){
          console.log(res)
        }
      })
      console.log(this.data)
      that.upload()
      that.upload1()
      that.upload2()
      that.upload3()
      that.upload4()
      that.upload5()
      that.upload6()
      that.upload7()
    }
    else{
      console.log(that.data.clientIdNumber.length)
      console.log(that.data.phoneNumber.length)
      console.log(that.data.carNumber.length)
      wx.showToast({
        title: '请校对身份证位数',
        icon:'error'
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})